package com.hd.assistant.dal.dao.query;

import java.io.Serializable;

public class BasePagerQuery implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer totalCount;
	private Integer page = 1;
	private Integer startRow = 0;
	private Integer pageSize = 20;
	private Integer totalPage;
	private boolean hasNext = true;
	public boolean hasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public Integer getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}
	public Integer getStartRow() {
		return startRow;
	}
	public void setStartRow(Integer startRow) {
		this.startRow = startRow;
	}
	
	public Integer getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
		int totalPage = this.totalCount/pageSize;
		if(this.totalCount % pageSize != 0)
			totalPage = totalPage+1;
		this.totalPage = totalPage;
		this.hasNext = this.totalPage > page;
	}
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
		this.startRow = page>0 ? ((page-1)*pageSize) : 0;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
		this.startRow = page>0 ? ((page-1)*pageSize) : 0;
	}
	public Integer nextPage(){
		int next = this.page+1;
		return next>totalPage?totalPage:next;
	}
	public Integer prePage(){
		int pre = this.page - 1 ;
		return pre < 1 ? 1:pre;
	}
}
